<!-- 资源配置 -->
<div class="easyui-layout" data-options="fit:true,border:false">
    <div id="mainContent" data-options="region:'north',border:false" >
        <div class="searchIndex">
            <ul>
                <li>
                    <label>关键字:</label>
                    <input id="txtQueryResName" class="base-input" style="width:150px;">
                </li>
                <li>
                    <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-searchWin8',plain:true" onclick="queryResourcesByName()">查询</a>
                </li>
            </ul>
        </div>
    </div>
    <div data-options="region:'center',border:false">
        <div id="configurationButton" style="padding-left:10px;">
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-add-win8',plain:true" onClick="showResourceCreate()">新增资源</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-trackRecordwin8',plain:true" onClick="showResourceUpdate()">编辑资源</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-removeWin8',plain:true" onclick="deleteResources()">删除</a>
        </div>
        <table id="tblQueryResourceList"class="easyui-datagrid" 
        data-options="toolbar:'#configurationButton',pagination:true,fit:true,
        autoRowHeight:false,rownumbers:true,border:false,fitColumns:true,singleSelect:false,
        url:'',pageNumber:1">   
            <thead>
                <tr>
                    <th data-options="field:'menuId',hidden:true"></th>
                    <th data-options="field:'name',width:100,align:'center'">资源名称</th>
                    <th data-options="field:'source',width:100,align:'center'">资源值</th>
                </tr>
            </thead>
        </table>
    </div>
</div>

<div class="easyui-dialog" id="resourceDialog" title="资源配置" style="width:370px;height:180px;" data-options="closed:true,modal:true">
    <form id="formResource">  
        <div class="con_form">
            <ul>
                <li>
                    <label>资源名称:</label>
                    <input type="hidden" id="hdResourceId" name="hdResourceId" value=""/>
                    <input  id="txtResourceName" name="txtResourceName" class="easyui-validatebox base-input" style="width:200px;" data-options="required:true" maxlength="60">
                </li>
                <li>
                    <label>资源值:</label>
                    <input  id="txtResourceValue"   name="txtResourceValue" class="easyui-validatebox base-input" style="width:200px;" data-options="required:true" maxlength="250">
                </li>
                <center>
                    <a href="javascript:void(0);" class="easyui-linkbutton okButton"  onclick="saveOrUpdateResource()" data-options="iconCls:'icon-okWin8'" style="margin-top:15px;">确认</a>
                </center>
            </ul>
        </div>
    </form>
</div>

<script>
    var reMenuId="";
    function selectMenuRowForResource(data){
        
        var rows=$("#tblQueryMenuList").datagrid("getRows");
        if(reMenuId && reMenuId!=""){
           for(var i=0;i<rows.length;i++){
               if(reMenuId == rows[i].id){
                  var ix=$("#tblQueryMenuList").datagrid("getRowIndex",rows[i]);
                  $("#tblQueryMenuList").datagrid("selectRow",ix);
               }
           }
        }
    }

    function showResourceCreate(){
        
          $("#formResource").form("reset"); 
          $("#hdResourceId").val("");
          $("#txtResourceName").removeAttr("disabled"); 
          //去掉按Enter键事件
          document.onkeydown = "";
          $("#resourceDialog").dialog("open");
          setFocus($("#txtResourceName"));
    }

    function showResourceUpdate(){
        
        $("#formResource").form("reset");
        var rows=$("#tblQueryResourceList").datagrid("getSelections");
        if(!rows||(rows&&rows.length!=1)){
           //去掉按Enter键事件
           document.onkeydown = "";
           var msgResource_1 = $.messager.alert( "提示","请选择一行记录!", "info");
           //捕捉messager关闭事件
           msgResource_1.window({onClose:function(){
                dialogClose();
            }});    
           return ;
        }
        var row=rows[0];
        $("#hdResourceId").val(row.id);
        $("#txtResourceName").val(row.name);
        $("#txtResourceName").validatebox({    
           required: false 
        });  
        $("#txtResourceName").attr("disabled","disabled"); 
        $("#txtResourceValue").val(row.source);
        $("#hdMenuId").val(row.menuId);
        $("#txtMenuName").val(row.menuName);
        $("#formResource").form("validate");
        //去掉按Enter键事件
        document.onkeydown = "";
        $("#resourceDialog").dialog("open");
        setFocus($("#txtResourceName"));
    }
</script>